package caipu;

import uitl.penuitl;

public class TextDemo {
	public static void main(String[] args) {
		AddressBook Ab = new AddressBook();
		while (true) {
			主页();
			int num = penuitl.penInt("请选择操作:");
			if (num == 1) {
				int id = penuitl.penInt("请输入编号:");
				String name = penuitl.penString("请输入菜谱名称:");
				double price = penuitl.penDouble("请输入价格:");
				Ab.Add(id, name, price);
			} else if (num == 2) {
				int id = penuitl.penInt("请输入编号:");
				Ab.Delete(id);
			} else if (num == 3) {
				int id = penuitl.penInt("请输入编号:");
				String name = penuitl.penString("请输入菜谱名称:");
				double price = penuitl.penDouble("请输入价格:");
				Ab.Modify(id, name, price);
			} else if (num == 4) {
				while (true) {
					System.out.println("                  [查询菜单]");
					System.out.println("          [1]按菜谱编号查询:" + "\n" + "          [2]按菜谱名称查询:" + "\n"
							+ "          [3]按价格查询:" + "\n" + "          [4]退出:");
					int id = penuitl.penInt("          请选择操作:");
					if (id == 4) {
						break;
					} else {
						Ab.Qyery(id);
					}
				}
			} else if (num == 5) {
				Ab.YL();
			} else {
				break;
			}
		}
	}

	public static void 主页() {
		System.out.println("                菜谱管理系统");
		System.out.println("***********************************");
		System.out
				.println("[1]增加" + "\n" + "[2]删除" + "\n" + "[3]修改" + "\n" + "[4]查询" + "\n" + "[5]阅览" + "\n" + "[0]退出");
		System.out.println("***********************************");
	}

}
